﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownList2.Items.Add("福建");
                DropDownList2.Items.Add("江西");
                DropDownList2.Items.Add("广西");
                DropDownList3.Items.Add("龙岩");
                DropDownList3.Items.Add("厦门");
                DropDownList3.Items.Add("漳州");
            }
        }

        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            string province = DropDownList2.SelectedValue;
            DropDownList3.Items.Clear();

            if (province == "福建")
            {
                DropDownList3.Items.Add("龙岩");
                DropDownList3.Items.Add("厦门");
                DropDownList3.Items.Add("漳州");
            }
            else if (province =="江西")
            {
                DropDownList3.Items.Add("景德镇");
                DropDownList3.Items.Add("九江");
                DropDownList3.Items.Add("鹰潭");
            }
            else
            {
                DropDownList3.Items.Add("南宁");
                DropDownList3.Items.Add("桂林");
                DropDownList3.Items.Add("崇左");
            }     
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            this.Literal1.Text = $"用户名：{TextBox1.Text},性别：{DropDownList1.Text},省：{DropDownList2.Text},市：{DropDownList3.Text},爱好：{TextBox3.Text}";
        }
    }
}